<?php
$select_avatar = mysql_query('SELECT * FROM avatars WHERE from_who="'.$_SESSION['username'].'" LIMIT 1');
$row_avatar = mysql_fetch_assoc($select_avatar);

$select_users=mysql_query('SELECT type, username FROM users WHERE username="'.$_SESSION['username'].'"');
$row_users=mysql_fetch_assoc($select_users);

echo "<p class='hello'>Здравей, <b>".$_SESSION['username']."</b> | <a href='../register/logout.php' class='logged_link'>Излез</a></p>";

if(mysql_num_rows($select_avatar)==0){
   echo '<img src="../user_pics/default.png" width="70" height="70" class="logged_pict" alt="avatar"/>';
} else {
   echo '<img src="../user_pics/'.$row_avatar['pic_name'].'" width="70" height="70" class="logged_pict" alt="avatar"/>';
}

   echo '<p style="float: right; position: relative; top: -40px; margin-right: 50px;">';
   if($row_users['type']==1){
      echo '<a href="../users/panel.php" class="logged_link">Панел</a>';
   } else if($row_users['type']==2){
      echo '<a href="../moderator/panel.php" class="logged_link">Панел</a>';
   } else if($row_users['type']==3){
      echo '<a href="../admin/panel.php" class="logged_link">Панел</a>';
   }
   echo ' | ';
   echo '<a href="../user_message/messages.php" class="logged_link">Съобщения</a>';
   echo ' | ';
   echo '<a href="../user_profile/profile.php" class="logged_link">Профил</a>';
   echo '</p>';
?>